clear
use Israel.popularity.dta, clear
tsset mydate
set matsize 800

*** Main models
** discriptive statistics
sum sat dccitotal pievent nievent pdevent ndevent npersonalevent war terror fi pi notpmpartyAI pmpartyAI notpmpartyRice

** Figure 2
tsline sat, scheme(s2color) legend(off) ytitle("Prime Ministerial Popularity") xtitle("") yscale(range(0 100))  ylabel(0(50)100) ymtick(0(50)100)  ylabel(0 "0" 20 "20" 40 "40" 60 "60" 80 "80" 100 "100") ttick(2006m1, tpos(in)) tline(2001m1, lpattern(dash)) tlabel(, angle(45) format(%-tmMon_CCYY)) ttick(2009m3, tpos(in)) tline(2009m3, lpattern(dash)) tlabel(, angle(45) format(%-tmMon_CCYY))

** Table 1
reg sat l.sat l.dccitotal l.war l.terror pievent nievent pdevent ndevent npersonalevent, vce(robust) 
reg sat l.sat l.dccitotal l.war l.terror pievent nievent pdevent ndevent npersonalevent l.notpmpartyAI l.pmpartyAI, vce(robust)
reg sat l.sat l.dccitotal l.war l.terror pievent nievent pdevent ndevent npersonalevent l.fi l.pi, vce(robust)
reg sat l.sat l.dccitotal l.war l.terror pievent nievent pdevent ndevent npersonalevent l.notpmpartyAI l.fi, vce(robust)

** Figure 3
reg sat l.sat l.dccitotal l.war l.terror pievent nievent pdevent ndevent npersonalevent l.fi l.pi, vce(robust)
margins, at(l.fi=(0(.1).80)) atmeans noatlegend
marginsplot, yscale(range(26 28 30 32 34 36 38 40)) recastci(rspike) xtitle("Fractionalization Index") ytitle("Linear Prediction of Satisfaction") title("") saving(fi, replace)

reg sat l.sat l.dccitotal l.war l.terror pievent nievent pdevent ndevent npersonalevent l.fi l.pi, vce(robust)
margins, at(l.pi=(.0(.02).12)) atmeans noatlegend
marginsplot, yscale(range(26 28 30 32 34 36 38 40)) recastci(rspike) xtitle("Polarization Index") ytitle("Linear Prediction of Satisfaction") title("") saving(pi, replace)

reg sat l.sat l.dccitotal l.war l.terror pievent nievent pdevent ndevent npersonalevent l.notpmpartyAI l.pmpartyAI, vce(robust)
margins, at(l.notpmpartyAI=(.8(.02)1)) atmeans noatlegend
marginsplot, yscale(range(30 32 34 36 38 40)) recastci(rspike) xtitle("Cohesion - Coalition Parties") ytitle("Linear Prediction of Satisfaction") title("") saving(legi, replace)

reg sat l.sat l.dccitotal l.war l.terror pievent nievent pdevent ndevent npersonalevent l.notpmpartyAI l.pmpartyAI, vce(robust)
margins, at(l.pmpartyAI=(.92(.01)1)) atmeans noatlegend
marginsplot, yscale(range(30 32 34 36 38 40)) recastci(rspike) xtitle("Cohesion - PM's Party") ytitle("Linear Prediction of Satisfaction") title("") saving(legi2, replace)


** Table 2
var sat notpmpartyAI fi dccitotal, lags(1) exog(pievent nievent pdevent ndevent npersonalevent l.war l.terror)
vargranger


** Table A5
reg sat l.sat l.dccitotal pievent nievent pdevent ndevent npersonalevent l.war l.terror l.notpmpartyRice l.fi, vce(robust)
reg sat l.sat l.dccitotal pievent nievent pdevent ndevent npersonalevent l.war l.terror l.notpmpartyAI l.fi l.coalsize, vce(robust)
reg sat l.sat l.dccitotal pievent nievent pdevent ndevent npersonalevent l.security l.notpmpartyAI l.fi, vce(robust)

** Table A6
reg sat l.sat l.dccitotal l.war l.terror pievent nievent pdevent ndevent npersonalevent l.notpmpartyAI l.fi, vce(robust)
vif


* Table A7
reg sat l.sat l.dccitotal pievent nievent pdevent ndevent npersonalevent l.war l.terror, vce(robust) 
margins, at(l.dccitotal=(-12.776 9.706))
margins, at(l.war=(0 5.231109))
margins, at(l.terror=(0 4.521789))
margins, at(pievent=(0 1))
margins, at(nievent=(0 1))
margins, at(pdevent=(0 1))
margins, at(ndevent=(0 1))
margins, at(npersonalevent=(0 1))

reg sat l.sat l.dccitotal pievent nievent pdevent ndevent npersonalevent l.war l.terror l.notpmpartyAI l.pmpartyAI, vce(robust)
margins, at(l.dccitotal=(-12.776 9.706))
margins, at(l.war=(0 5.231109))
margins, at(l.terror=(0 4.521789))
margins, at(pievent=(0 1))
margins, at(nievent=(0 1))
margins, at(pdevent=(0 1))
margins, at(ndevent=(0 1))
margins, at(npersonalevent=(0 1))
margins, at(l.notpmpartyAI=(.8029692 1))
margins, at(l.pmpartyAI=(.9372965 1))

reg sat l.sat l.dccitotal pievent nievent pdevent ndevent npersonalevent l.war l.terror l.fi l.pi, vce(robust)
margins, at(l.dccitotal=(-12.776 9.706))
margins, at(l.war=(0 5.231109))
margins, at(l.terror=(0 4.521789))
margins, at(pievent=(0 1))
margins, at(nievent=(0 1))
margins, at(pdevent=(0 1))
margins, at(ndevent=(0 1))
margins, at(l.fi=(0 .7829335))
margins, at(l.pi=(0 .1225904))

reg sat l.sat l.dccitotal pievent nievent pdevent ndevent npersonalevent l.war l.terror l.notpmpartyAI l.fi, vce(robust)
margins, at(l.dccitotal=(-12.776 9.706))
margins, at(l.war=(0 5.231109))
margins, at(l.terror=(0 4.521789))
margins, at(pievent=(0 1))
margins, at(nievent=(0 1))
margins, at(pdevent=(0 1))
margins, at(ndevent=(0 1))
margins, at(npersonalevent=(0 1))
margins, at(l.notpmpartyAI=(.8029692 1))
margins, at(l.fi=(0 .7829335))

